~ chicken-core (master) /manual/Module (chicken pathname)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken pathname)
  5
  6This module provides procedures for manipulating paths.  If you want
  7to operate on the files and directories which the paths represent, see
  8[[Module (chicken file)]].
  9
 10=== absolute-pathname?
 11
 12<procedure>(absolute-pathname? PATHNAME)</procedure>
 13
 14Returns {{#t}} if the string {{PATHNAME}} names an absolute
 15pathname, and returns {{#f}} otherwise.
 16
 17=== decompose-pathname
 18
 19<procedure>(decompose-pathname PATHNAME)</procedure>
 20
 21Returns three values: the directory-, filename- and extension-components
 22of the file named by the string {{PATHNAME}}.
 23For any component that is not contained in {{PATHNAME}}, {{#f}} is returned.
 24
 25=== make-pathname
 26=== make-absolute-pathname
 27
 28<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION])</procedure><br>
 29<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION])</procedure>
 30
 31Returns a string that names the file with the
 32components {{DIRECTORY, FILENAME}} and (optionally)
 33{{EXTENSION}} with {{SEPARATOR}} being the directory separation indicator
 34({{/}}). 
 35{{DIRECTORY}} can be {{#f}} (meaning no
 36directory component), a string or a list of strings. {{FILENAME}}
 37and {{EXTENSION}} should be strings or {{#f}}.
 38{{make-absolute-pathname}} returns always an absolute pathname.
 39
 40=== pathname-directory
 41=== pathname-file
 42=== pathname-extension
 43
 44<procedure>(pathname-directory PATHNAME)</procedure><br>
 45<procedure>(pathname-file PATHNAME)</procedure><br>
 46<procedure>(pathname-extension PATHNAME)</procedure>
 47
 48Accessors for the components of {{PATHNAME}}. If the pathname does
 49not contain the accessed component, then {{#f}} is returned.
 50
 51=== pathname-replace-directory
 52=== pathname-replace-file
 53=== pathname-replace-extension
 54
 55<procedure>(pathname-replace-directory PATHNAME DIRECTORY)</procedure><br>
 56<procedure>(pathname-replace-file PATHNAME FILENAME)</procedure><br>
 57<procedure>(pathname-replace-extension PATHNAME EXTENSION)</procedure>
 58
 59Return a new pathname with the specified component of {{PATHNAME}}
 60replaced by a new value.
 61
 62=== pathname-strip-directory
 63=== pathname-strip-extension
 64
 65<procedure>(pathname-strip-directory PATHNAME)</procedure><br>
 66<procedure>(pathname-strip-extension PATHNAME)</procedure>
 67
 68Return a new pathname with the specified component of {{PATHNAME}}
 69stripped.
 70
 71=== normalize-pathname
 72
 73<procedure>(normalize-pathname PATHNAME [PLATFORM])</procedure>
 74
 75Performs a simple "normalization" on the {{PATHNAME}}, suitably for
 76{{PLATFORM}}, which should be one of the symbols {{windows}}
 77or {{unix}} and defaults to on whatever platform is currently
 78in use. All relative path elements and duplicate separators are processed 
 79and removed.  If {{NAME}} ends with
 80a {{/}} or is empty, a slash is appended to the tail.
 81
 82No directories or files are actually tested for existence; this 
 83procedure only canonicalises path syntax.
 84
 85=== directory-null?
 86
 87<procedure>(directory-null? DIRECTORY)</procedure>
 88
 89Does the {{DIRECTORY}} consist only of path separators and the period?
 90
 91{{DIRECTORY}} may be a string or a list of strings.
 92
 93=== decompose-directory
 94
 95<procedure>(decompose-directory DIRECTORY)</procedure>
 96
 97Returns 3 values: the {{base-origin}}, {{base-directory}}, and the
 98{{directory-elements}} for the {{DIRECTORY}}.
 99
100; {{base-origin}} : a {{string}} or {{#f}}. The drive, if any.
101; {{base-directory}} : a {{string}} or {{#f}}. A directory-separator when {{DIRECTORY}} is an {{absolute-pathname}}.
102; {{directory-elements}} : a {{list-of string}} or {{#f}}. The non-directory-separator bits.
103
104{{DIRECTORY}} is a {{string}}.
105
106* On Windows {{(decompose-directory "c:foo/bar")}} => {{"c:" #f ("foo" "bar")}}
107
108=== Windows specific notes
109
110Use of UTF8 encoded strings for pathnames is not supported. Windows
111uses a 16-bit UNICODE encoding with special system calls for
112wide-character support.  Only single-byte string encoding can be used.
113
114---
115Previous: [[Module (chicken number-vector)]]
116
117Next: [[Module (chicken platform)]]
Trap